package cn.bellychang.command.demo01;

/**
 * 问题1：SmartControl知道了太多其不应该知道的细节
 * 问题2：代码写死了，不符合开闭OCP原则 比如说我想加入一个空调遥控器，就需要修改代码
 * @author ChangLiang
 * @date 2020/4/14
 */
public class SmartControl {

    Door door = new Door();
    Light light = new Light();
    Tv tv = new Tv();

    public void onButtonPressed(int slot) {
        switch (slot) {
            case 0:
                door.on();
                break;
            case 1:
                light.on();
                break;
            case 2:
                tv.on();
                break;
            default:
                break;
        }
    }

    public void offButtonPressed(int slot) {
        switch (slot) {
            case 0:
                door.off();
                break;
            case 1:
                light.off();
                break;
            case 2:
                tv.off();
                break;
            default:
                break;
        }
    }
}
